package com.avic.rong.adapter.show;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.avic.rong.R;
import com.avic.rong.adapter.PublicNumberAdapter;
import com.avic.rong.bean.AdvBean;
import com.avic.rong.bean.show_bean.TypeBean;
import com.avic.rong.questionOrAnswer.activity.PersonalHomeActivity;
import com.avic.rong.utils.StringUtils;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.example.minato.minastore.utils.GlideApp;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by TSJ-2018-0492 on 2019/9/11.
 */

public class GuangGaoAdapter extends RecyclerView.Adapter<GuangGaoAdapter.Viewholder> {
    private Context mContext;
    private List<AdvBean> advertismentList;

    public GuangGaoAdapter(Context mContext) {
        this.mContext = mContext;
    }

    public void setAdvertismentList(List<AdvBean> advertismentList) {
        this.advertismentList = advertismentList;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public GuangGaoAdapter.Viewholder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.artic_guanggao_item, viewGroup, false);
        return new Viewholder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull GuangGaoAdapter.Viewholder viewholder, int i) {
        if (!StringUtils.isEmpty(advertismentList.get(i).getContent())){
            Glide.with(mContext).load(advertismentList.get(i).getContent()).error(R.mipmap.error)
                    .apply(RequestOptions.bitmapTransform(new RoundedCorners(5))).into(viewholder.guanggao_image);
        }else{
            viewholder.guanggao_image.setVisibility(View.GONE);
        }
    }



    @Override
    public int getItemCount() {
        if (advertismentList!=null){
            return advertismentList.size();
        }
        return 0;
    }


    public class Viewholder extends RecyclerView.ViewHolder {

        private  ImageView guanggao_image;

        public Viewholder(@NonNull View itemView) {
            super(itemView);
            guanggao_image = itemView.findViewById(R.id.guanggao_image);
        }
    }
}
